#!/usr/bin/python3
# -*- coding:utf-8 -*-
import sys
import os
libdir = "/home/pi/src/e-Paper/RaspberryPi_JetsonNano/python/lib"
picdir = "/home/pi/src/e-Paper/RaspberryPi_JetsonNano/python/pic"
if os.path.exists(libdir):
    sys.path.append(libdir)

import logging
from waveshare_epd import epd7in5_V2
import time
from PIL import Image,ImageDraw,ImageFont
import traceback

logging.basicConfig(level=logging.DEBUG)

try:
    epd = epd7in5_V2.EPD()
    
    epd.init()
#    epd.Clear()
    Himage = Image.open(os.path.join(picdir, '/tmp/weather/weather.bmp')).transpose(Image.ROTATE_180)
    epd.display(epd.getbuffer(Himage))

    epd.sleep()
    
except IOError as e:
    logging.info(e)
    
except KeyboardInterrupt:    
    logging.info("ctrl + c:")
    epd7in5_V2.epdconfig.module_exit()
    exit()
